﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System;

public class RecordCell : MonoBehaviour {

	// Use this for initialization
	public Zjh.RecordInfo data = null;

	public int heights = 195;
	void Start () {

		if (data == null) {
			return;
		}
		transform.GetChild (2).GetComponent<Text> ().text = data.time;
		transform.GetChild (4).GetComponent<Text> ().text = "扎金花: "+data.players+"人 "+data.rounds+"局";

		for( int i = 0 ; i < data.items.Count ; i++ ){
			if (data.items [i].nickName.Length < 10) {
				transform.GetChild (i + 5).GetChild (0).GetComponent<Text> ().text = data.items [i].nickName.ToString ();
			} else {
				transform.GetChild (i + 5).GetChild (0).GetComponent<Text> ().text = data.items [i].nickName.Substring (0, 9);
			}
		
			transform.GetChild (i + 5).GetChild (0).GetComponent<Text> ().text += "( ID:" + data.items [i].playerId.ToString () +")";
			transform.GetChild (i + 5).GetChild (1).GetComponent<Text> ().text = data.items [i].cedit.ToString();

			if( data.items [i].cedit > 0 ){
				transform.GetChild (i + 5).GetChild (1).GetComponent<Text> ().color = Color.red;
				transform.GetChild (i + 5).GetChild (1).GetComponent<Text> ().text = "+"+data.items [i].cedit.ToString();
			}else{
				transform.GetChild (i + 5).GetChild (1).GetComponent<Text> ().text = data.items [i].cedit.ToString();
			}

		}

	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
